#if !defined(AFX_SIMDIWND_H__ECD29FAC_F325_478A_BA79_C59B5AA6C7A4__INCLUDED_)
#define AFX_SIMDIWND_H__ECD29FAC_F325_478A_BA79_C59B5AA6C7A4__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SiMDIWnd.h : header file
//
#include "SubclassWnd.h"
#include "MdiChildManagment.h"

/////////////////////////////////////////////////////////////////////////////
// CSiMDIWnd window

class CSiMDIWnd : public CSubclassWnd
{
// Construction
public:
	CSiMDIWnd();
	virtual ~CSiMDIWnd();

	void Attach(HWND hWnd);
	HWND Detach();

// Attributes
public:
	RECT& GetBorder() { return m_Border; }
	void SetBorder(const LPRECT lpRect) { ::CopyRect(&m_Border,lpRect);}
	bool SetManaging(bool bManaging);
	bool GetManaging() { return m_bManaging; };
	bool SetMakeSpace(bool bMakeSpace);
	void SetTabbarWnd(HWND hTabWnd) { m_hTabbarWnd = hTabWnd; };
// Operations
public:


// Implementation
public:
	virtual LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
	virtual void PreSubclassWindow();

	void PostUpdateMessage();

	int EnumMdiChildWnd(CMdiChildManagment& ChildWndMng, BOOL bRemoveExist);
	HWND MDIGetActive(BOOL *pbMaximized = NULL);
	void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos);
	LRESULT OnUpdateTabs(WPARAM wParam, LPARAM lParam);

protected:
	HWND  m_hTabbarWnd;
	RECT  m_Border;
	bool  m_bMakeSpace;
	bool  m_bManaging;
	bool  m_bUpdatePosted;
	RECT  m_LastPos;
	int   m_iTabHeight;
	int   m_iTabWidth;

	void CheckTabCount();
	void ForceRedraw();
	void ReclameTabSpace();
	void UpdateTabSizeAndPosition(RECT& WndRect);
	void UpdateTabSize();

	SIZE CalcTabsSize(SnapOrientations o) const;
	bool CalcTabsPosition(RECT& WndRect, RECT& TabsRect,SnapOrientations o) const;

};


#endif // !defined(AFX_SIMDIWND_H__ECD29FAC_F325_478A_BA79_C59B5AA6C7A4__INCLUDED_)
